#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define mod 1000000007
#define ll long long
#define ull unsigned long long
#define mem(a) memset(a, 0, sizeof(a))
#define cio ios::sync_with_stdio(false);
struct node
{
    double x, y, z;
} q[10100000];
bool cmp(node a, node b)
{
    return a.z < b.z;
}
int vis[10100000];
int n, h, r;
int flag;
double dis(double x1, double y1, double z1, double x2, double y2, double z2)
{
    return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) + (z1 - z2) * (z1 - z2)); //计算两空洞距离
}
void dfs(int p)
{
    if (q[p].z + r >= h)
    {             //到达上表面
        flag = 1; //标记
        return;
    }
    if (flag == 1)
        return; //已到达上表面停止搜索
    vis[p] = 1; //标记已走过得空洞
    for (int i = 0; i < n; i++)
    {
        if (vis[i] == 0 && dis(q[p].x, q[p].y, q[p].z, q[i].x, q[i].y, q[i].z) <= 2 * r)
        {
            dfs(i); //进入与当前空洞相连并且没走过得空洞继续搜索
        }
    }
}

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        cin >> n >> h >> r;
        mem(q);
        mem(vis);
        for (int i = 0; i < n; i++)
            cin >> q[i].x >> q[i].y >> q[i].z;
        sort(q, q + n, cmp); //按照每个空洞得高从小到大排序
        flag = 0;
        for (int i = 0; i < n; i++)
        {
            if (q[i].z <= r)
            { //直接与下表面接触得开始搜索
                dfs(i);
            }
            else
            {
                break; //因为排序过，所以当该空洞不与下表面接触，后面得空洞也不会（小优化）
            }
            if (flag)
                break; //可以到达上表面结束搜索
        }
        if (flag)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
    return 0;
}